package com.zyf.pattern.singleton.seriable;

import java.io.Serializable;

/**
 * 序列化与反序列化保证单例
 * 重写readResolve
 * create by yifeng
 */
public class Seriable implements Serializable {
    public final static Seriable INSTANCE = new Seriable();
    private Seriable() {}
    public static Seriable getInstance() {
        return INSTANCE;
    }

    // 重写此方法，即可使序列化单例
    private Object readResolve() {
        return INSTANCE;
    }
}
